<?php
  $orderStatus = $this->idOrderLine['order_status'];
  
  $actBtn = ($orderStatus < 10)?'':' disabled="disabled"';

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.0/css/jquery.dataTables.css">

<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script>

<script type="text/javascript" language="javascript" class="init">

jQuery.fn.dataTableExt.oApi.fnGetHiddenNodes = function ( settings )
{
    var nodes;
    var display = jQuery('tbody tr', settings.nTable);
 
    if ( jQuery.fn.dataTable.versionCheck ) {
        // DataTables 1.10
        var api = new jQuery.fn.dataTable.Api( settings );
        nodes = api.rows().nodes().toArray();
    }
    else {
        // 1.9-
        nodes = this.oApi._fnGetTrNodes( settings );
    }
 
    /* Remove nodes which are being displayed */
    for ( var i=0 ; i<display.length ; i++ ) {
        var iIndex = jQuery.inArray( display[i], nodes );
 
        if ( iIndex != -1 ) {
            nodes.splice( iIndex, 1 );
        }
    }
 
    return nodes;
};

$(document).ready(function() {
   oTable = $('#product_table').dataTable();
    
   $('form').submit(function(){
      $(oTable.fnGetHiddenNodes()).find('input:text').appendTo(this);
   });
} );


	</script>
<body  >
<div style="font-family:Arial, Helvetica, sans-serif;" >
<h1>Modify Order:</h1>

<form id="form1" name="form1" method="post" action="">

<p><br />
  Add BarCode :
  <label for="is_urgent"></label>
  <select name="is_urgent" id="is_urgent">
    <option value="NU">Not Urgent</option>
    <option value="U">Urgent</option>
    <option value="VU">Very Urgent</option>
  </select>
  <label for="code_add"></label>
  <input type="text" name="code_add" id="code_add" style="width:200px;" />
Qty  
<input name="qty_order" type="text" id="qty_order" style="width:50px;" value="1" />
  <input type="submit" name="btn_add_code" id="btn_add_code" value="Add Barcode"  <?php echo $actBtn;?>  />
  <br />
  <br />
  <br />
  <input type="submit" name="btn_save" id="btn_save" value="Save Changes" <?php echo $actBtn;?>  />
  <br />
  <br />
</p>
<table width="1100" border="1" cellspacing="0" cellpadding="10" style="font-size:13px;" id="product_table">
  <thead> 
  <tr>
    <th rowspan="2" scope="col">No</th>
    <th rowspan="2" scope="col">Urgent</th>
    <th rowspan="2" scope="col">Code</th>
    <th width="350" rowspan="2" scope="col">Des</th>
    <th colspan="3" scope="col">Sales<br /></th>
    <th colspan="2" scope="col">Stock</th>
    <th rowspan="2" scope="col">Order</th>
    <th rowspan="2" scope="col">Loc</th>
  </tr>

  <tr>
    <th scope="col">2Wk <br />
      Ago</th>
    <th scope="col">Last<br />
      Wk</th>
    <th scope="col">Max<br />
      4Wk</th>
    <th scope="col">SH</th>
    <th scope="col">WH</th>
  </tr>
 </thead> 
 <tfoot> 
  <tr>
    <th rowspan="2" scope="col">No</th>
    <th rowspan="2" scope="col">Urgent</th>
    <th rowspan="2" scope="col">Code</th>
    <th width="350" rowspan="2" scope="col">Des</th>
    <th colspan="3" scope="col">Sales<br /></th>
    <th colspan="2" scope="col">Stock</th>
    <th rowspan="2" scope="col">Order</th>
    <th rowspan="2" scope="col">Loc</th>
  </tr>

  <tr>
    <th scope="col">2Wk <br />
      Ago</th>
    <th scope="col">Last<br />
      Wk</th>
    <th scope="col">Max<br />
      4Wk</th>
    <th scope="col">SH</th>
    <th scope="col">WH</th>
  </tr>
 </tfoot>  
 <tbody>
  <?php 
  
  $locs = new Model_Products_Location();
  

  
  foreach($this->orderList as $k => $v){?>
  <tr >
    <td align="center"><?php echo $k + 1;?></td>
    <td><?php echo $v['status_hot'];?></td>
    <td><span <?php  
	if($v['is_extra'] == 1){echo 'style="background:#6666CC;"'; }
	if($v['is_extra'] == 2){echo 'style="background:#99CCFF;"'; }
	?>
	><?php echo $v['code_product'];?></span></td>
    <td><span <?php 
	if($v['is_extra'] == 1){echo 'style="background:#6666CC;"'; }
	if($v['is_extra'] == 2){echo 'style="background:#99CCFF;"'; }
	
	?> ><?php echo $v['des_product'];?></span></td>
    <td align="center"><?php echo $v['qty_sales_w2'];?></td>
    <td align="center"><?php echo $v['qty_sales_w1'];?></td>
    <td align="center"><?php echo $v['qty_max_sold'];?></td>
    <td align="center"><?php echo $v['stock_shop'];?></td>
    <td align="center"><?php echo $v['stock_wh'];?></td>
    <td align="center"><span style="color:#FFF;"><?php echo $v['qty_order'];?></span>
      <input type="text" name="qty_order[<?php echo $v['id_order'];?>]" id="qty_order<?php echo $v['id_order'];?>"  style="width:25px; text-align:center;" value="<?php echo $v['qty_order'];?>"/></td>
    <td><?php 
    
    $rows = $locs->getLocationsByProduct($v['code_product']);
    if(!empty($rows)){
    	foreach($rows as $row){ echo $row['code_location'].",";}
    }
    else{
    	echo "-";
    }
    ?></td>
  </tr>
  <?php }?>
  </tbody>
  
</table>
<br />
<br />
<input type="submit" name="btn_save2" id="btn_save2" value="Save Changes"  <?php echo $actBtn;?>  />
 <input type="submit" name="btn_gen_excel" id="btn_gen_excel" value="Generate Excel File" disabled="disabled" />
 <input type="submit" name="btn_lock" id="btn_lock" value="Lock Order,Notify China"  <?php echo $actBtn;?> />
 <br />
</form>
</div>
</body>
</html>
